<?php

namespace wicked\tools;

trait StaticAccessor
{

    public static function __callStatic($field, $value)
    {
        if(method_exists(get_called_class(), $field))
        {
            forward_static_call_array($field, $value);
        }
        elseif(property_exists(get_called_class(), $field))
        {
            if(empty($value))
                return static::${$field};
            else
            {
                if(is_array(static::${$field}))
                {
                    if(isset($value[1]))
                        static::${$field}[$value[0]] = $value[1];
                    else
                        return static::${$field}[$value[0]];
                }
                else
                    static::${$field} = $value[0];
            }
        }
    }

}
